<template>
  <div class="marketTab">
    <div class="marketTabItem" v-for="(item,index) in tabList" @click="changeTab(item.code)"
         :class="{active:activeCode === item.code}"
    >{{ item.name }}
    </div>
  </div>
</template>

<script lang="ts" setup>
const emit = defineEmits(['changeTab']);

interface Props {
  marketCode?: string;
  tabList?: any;
}

const {
  marketCode,
  tabList
} = defineProps<Props>();
let activeCode = ref('')
activeCode.value = tabList[0].code
const changeTab = (type: string) => {
  if (activeCode.value !== type) {
    activeCode.value = type
    emit('changeTab', activeCode.value)
  }
}
</script>

<style scoped lang="scss">
.marketTab {
  margin-bottom: 10px;

  .marketTabItem {
    display: inline-flex;
    align-items: center;
    color: #111;
    font-size: 14px;
    height: 100%;
    justify-content: center;
    cursor: pointer;
    font-weight: normal;
    margin-right: 16px;

    &.active {
      font-weight: bold;
    }
  }
}
</style>
